package com.battle.service.controller.web;

import com.battle.pojo.enums.CaseTypeEnum;
import com.battle.pojo.param.caseBaseInfo.*;
import com.battle.pojo.param.label.CreateLabelParam;
import com.battle.pojo.param.labelMp.CreateLabelMpParam;
import com.battle.pojo.vo.CityVo;
import com.battle.pojo.vo.caseBaseInfo.*;
import com.battle.service.service.in.*;
import com.battle.service.utils.CityUtil;
import nirvana.core.domains.vo.PageResult;
import nirvana.core.domains.vo.ApiResult;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

import java.util.List;
import java.util.Map;

/**
 * web/战例
 * 【描 述】：
 * 【环 境】：J2SE
 * 【详 细】：
 */
@RestController
@RequestMapping("/caseBaseInfo/web")
public class CaseBaseInfoWebController {

    private final CaseBaseInfoService service;
    private final LabelMpService labelMpService;

    public CaseBaseInfoWebController(CaseBaseInfoService service, LabelMpService labelMpService) {
        this.service = service;
        this.labelMpService = labelMpService;
    }

    /**
     * 创建战例
     *
     * @param param
     * @return
     */
    @PostMapping("/createCaseBaseInfo")
    public ApiResult createCaseBaseInfo(@RequestBody @Valid CreateCaseBaseInfoParam param) {
        return ApiResult.ok(service.createCaseBaseInfo(param));
    }

    /**
     * 上传战例
     *
     * @param param
     * @return
     */
    @PostMapping("/importCaseBaseInfo")
    public ApiResult importCaseBaseInfo(@RequestBody @Valid ImportCaseBaseInfoParam param) {
        service.importCaseBaseInfo(param);
        return ApiResult.ok();
    }

    /**
     * 修改战例
     *
     * @param param
     */
    @PutMapping("/editCaseBaseInfo")
    public ApiResult editCaseBaseInfo(@RequestBody @Valid EditCaseBaseInfoParam param) {
        service.editCaseBaseInfo(param);
        return ApiResult.ok();
    }

    /**
     * 获得战例下拉框
     * @param param
     * @return
     */
    @PostMapping("/getCaseBaseInfoDownList")
    public ApiResult<List<GetCaseBaseInfoDownListVo>> getCaseBaseInfoDownList(@RequestBody @Valid GetCaseBaseInfoDownListParam param) {
        List<GetCaseBaseInfoDownListVo> vo = service.getCaseBaseInfoDownList(param);
        return ApiResult.ok(vo);
    }

    /**
     * 撤回战例
     *
     * @param id
     * @return
     */
    @GetMapping("/revocationCase")
    public ApiResult revocationCase(@RequestParam("id") Long id) {
        service.revocationCase(id);
        return ApiResult.ok();
    }

    /**
     * 移除战例
     *
     * @param id
     * @return
     */
    @GetMapping("/removeCaseBaseInfo")
    public ApiResult removeCaseBaseInfo(@RequestParam("id") Long id) {
        service.removeCaseBaseInfo(id);
        return ApiResult.ok();
    }

    /**
     * 恢复战例
     *
     * @param id
     * @return
     */
    @GetMapping("/updateCaseDeleted")
    public ApiResult updateCaseDeleted(@RequestParam("id") Long id) {
        service.updateCaseDeleted(id);
        return ApiResult.ok();
    }


    /**
     * 审批战例
     *
     * @param param
     * @return
     */
    @PostMapping("/approveCase")
    public ApiResult approveCase(@RequestBody @Valid ApproveCaseParam param) {
        service.approveCase(param);
        return ApiResult.ok();
    }


    /**
     * 获取战例详情
     *
     * @param id
     * @return
     */
    @GetMapping("/getCaseBaseInfo")
    public ApiResult<GetCaseBaseInfoVo> getCaseBaseInfo(@RequestParam("id") Long id) {
        GetCaseBaseInfoVo vo = service.getCaseBaseInfo(id);
        return ApiResult.ok(vo);
    }

    /**
     * 查看审批情况，创建-提交-审批-发布
     *
     * @param id
     * @return
     */
    @GetMapping("/getCaseBaseInfoAudit")
    public ApiResult<CaseBaseInfoAuditVo> getCaseBaseInfoAudit(@RequestParam("id") Long id) {
        CaseBaseInfoAuditVo vo = service.getCaseBaseInfoAudit(id);
        return ApiResult.ok(vo);
    }


    /**
     * 获取战例列表
     *
     * @param param
     * @return
     */
    @PostMapping("/getCaseBaseInfoList")
    public ApiResult<PageResult<GetCaseBaseInfoListVo>> getCaseBaseInfoList(@RequestBody GetCaseBaseInfoListParam param) {
        PageResult<GetCaseBaseInfoListVo> result = service.getCaseBaseInfoList(param);
        return ApiResult.ok(result);
    }



    /**
     * 获取推荐的战例
     * @return
     */
    @GetMapping("/selectRecommendCaseList")
    public ApiResult<List<CaseHomePageVo>> selectRecommendCaseList() {
        return ApiResult.ok(service.selectRecommendCaseList());
    }

    /**
     * 获取待办审批的战例
     * @return
     */
    @GetMapping("/selectBacklogCaseList")
    public ApiResult<List<CaseHomePageVo>> selectBacklogCaseList() {
        return ApiResult.ok(service.selectBacklogCaseList());
    }

    /**
     * 获取战例统计信息
     * @return
     */
    @GetMapping("/selectCaseBaseInfo")
    public ApiResult<GetCaseBaseInfoQueryVo> selectCaseBaseInfo(@RequestParam("type")Integer type) {
        return ApiResult.ok(service.selectCaseBaseInfo(type));
    }

    /**
     * 获取城市下拉框
     * @return
     */
    @GetMapping("/getCascadingCities")
    public ApiResult< List<CityVo>> getCascadingCities() {
        List<CityVo> vo = service.getCityList();
        return ApiResult.ok(vo);
    }

}

